package cn.lx.expansion.dynamic2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @author lixin
 * @Classname SubjectDynamicProxy
 * @Description TODO
 * @Date 2019/10/5 下午4:30
 */
public class SubjectDynamicProxy extends DynamicProxy {

    public static <T> T newProxyInstance(Subject subject) {

        ClassLoader classLoader = subject.getClass().getClassLoader();
        Class<?>[] interfaces = subject.getClass().getInterfaces();
        InvocationHandler h = new MyInvocationHandler(subject);

        return newProxyInstance(classLoader, interfaces, h);
    }
}
